<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>example</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  <style>
    .demo-form {
      margin: 60px auto 0;
      width: 600px;
    }
  </style>
</head>
<body>
  <div class="container">
    <form class="demo-form">
      <div class="form-group">
        <label for="email">邮箱</label>
        <input data-dict="!zh" id="email" class="form-control" name="email" type="text" placeholder="请输入邮箱">
      </div>
      <div class="form-group">
        <label for="number">数字</label>
        <input data-dict="number" id="number" class="form-control" name="number" type="text" placeholder="请输入数字">
      </div>
      <div class="form-group">
        <label for="letter">字母</label>
        <input data-dict="letter" id="letter" class="form-control" name="letter" type="text" placeholder="请输入字母">
      </div>
      <div class="form-group">
        <label for="phone">手机号码</label>
        <input data-dict="number" id="phone" class="form-control" name="phone" type="text" placeholder="请输入手机号码">
      </div>
      <div class="form-group">
        <label for="numberLetter">数字和字母</label>
        <input data-dict="numberLetter" id="numberLetter" class="form-control" name="numberLetter" type="text" placeholder="请输入数字和字母">
      </div>
    </form>
  </div>

  <script src="../src/range.js"></script>
  <script>
    (function () {
      // 限制输入类型
      const dictMatch = {
        'number': /\D/g, // 只能输入数字
        'numberLetter': /[^A-Za-z0-9]/g, // 只能输入数字和字母
        'letter': /[^A-Za-z]/g, // 只能输入字母
        '!zh': /[\u4e00-\u9fa5]/g // 不能输入中文
      };
    }());
  </script>
</body>
</html>
